<#-- Copyright 2010 Canadensys -->
<#include "_inc/ftl/common.ftl">
<@assignTitle str=locale.checklist_title1/>
<#assign currentPage="checklist"/>
<#include "_inc/ftl/header.ftl">
<script type="text/javascript" src="js/checklist.js"></script>
<#include "_inc/ftl/menu.ftl">
<h1><@display str=locale.checklist_title1/></h1>
<form id="checklist_box" class="round custom_form" method="get">
	<ul class="custom_list" id="checklist_header">
		<li class="round big_button selected" id="selection_button" onclick="toggleDisplay('selection_criteria')"><@display str=locale.checklist_msg1/></li>
		<li class="round big_button" id="display_button" onclick="toggleDisplay('display_criteria')"><@display str=locale.checklist_msg2/></li>
	</ul>

	<div id="selection_criteria" class="checklist_content">
		<p class="alignright"><@display str=locale.checklist_msg4/>
		<input type="hidden" name="lang" value="${language}" />
		<select name="habit">
			<option <#attempt>${habit.all}<#recover></#attempt> value="all"><@display str=locale.checklist_option5/></option>
			<option <#attempt>${habit.tree}<#recover></#attempt> value="tree"><@display str=locale.habitus_tree/></option>
			<option <#attempt>${habit.shrub}<#recover></#attempt> value="shrub"><@display str=locale.habitus_shrub/></option>
			<option <#attempt>${habit.herb}<#recover></#attempt> value="herb"><@display str=locale.habitus_herb/></option>
			<option <#attempt>${habit.vine}<#recover></#attempt> value="vine"><@display str=locale.habitus_vine/></option>
		</select>
		</p>

		<p><@display str=locale.checklist_msg3/></p>
		<p>
			<select name="taxon" id="search_term">
				<option name="0" value="0">- <@display str=locale.checklist_msg9 /> -</option>
			<#list taxons as taxon>
				<option ${taxon.selected} name="${taxon.id}" value="${taxon.id}">${taxon.calname} (<@display str=("locale.rank_"+taxon.rank?lower_case)?eval />)</option>
			</#list>
			</select>
		<p>
		
		<p><@display str=locale.checklist_msg5/>
		<select name="combination">
			<option <#attempt>${combination.anyof}<#recover></#attempt> value="anyof"><@display str=locale.checklist_option2/></option>
			<option <#attempt>${combination.allof}<#recover></#attempt> value="allof"><@display str=locale.checklist_option1/></option>
			<option <#attempt>${combination.only}<#recover></#attempt> value="only"><@display str=locale.checklist_option3/></option>
			<option <#attempt>${combination.only_ca}<#recover></#attempt>value="only_ca"><@display str=locale.checklist_option4/></option>
		</select>
		<@display str=locale.checklist_msg6/></p>
		
		<!-- regions -->
		<div id="checklist_distribution">
			<ul class="custom_list round canada">
				<li><span><@display str=locale.region_canada/></span><input <#attempt>${territory.CANADA}<#recover></#attempt> type="checkbox" id="canada" /></li>
			</ul>
			<ul class="custom_list round pacific">
				<li><span><input type="checkbox" id="pacific"/><@display str=locale.region_pacific/></span><@display str=locale.province_BC/><input <#attempt>${territory.BC}<#recover></#attempt> type="checkbox" name="province" id="BC" value="BC" /></li>
			</ul>
			<ul class="custom_list round prairies">
				<li><span><input type="checkbox" id="prairies"/><@display str=locale.region_prairies/></span><@display str=locale.province_AB/><input <#attempt>${territory.AB}<#recover></#attempt> type="checkbox" name="province" id="AB" value="AB" /></li>
				<li><span></span><@display str=locale.province_SK/><input <#attempt>${territory.SK}<#recover></#attempt> type="checkbox" name="province" id="SK" value="SK" /></li>
				<li><span></span><@display str=locale.province_MB/><input <#attempt>${territory.MB}<#recover></#attempt> type="checkbox" name="province" id="MB" value="MB" /></li>
			</ul>
			<ul class="custom_list round central">
				<li><span><input type="checkbox" id="central"/><@display str=locale.region_central/></span><@display str=locale.province_ON/><input <#attempt>${territory.ON}<#recover></#attempt> type="checkbox" name="province" id="ON" value="ON" /></li>
				<li><span></span><@display str=locale.province_QC/><input <#attempt>${territory.QC}<#recover></#attempt> type="checkbox" name="province" id="QC" value="QC" /></li>
			</ul>
			<ul class="custom_list round atlantic">
				<li><span><input type="checkbox" id="atlantic"/><@display str=locale.region_atlantic/></span><@display str=locale.province_NB/><input <#attempt>${territory.NB}<#recover></#attempt> type="checkbox" name="province" id="NB" value="NB" /></li>
				<li><span></span><@display str=locale.province_PE/><input <#attempt>${territory.PE}<#recover></#attempt> type="checkbox" name="province" id="PE" value="PE" /></li>
				<li><span></span><@display str=locale.province_NS/><input <#attempt>${territory.NS}<#recover></#attempt> type="checkbox" name="province" id="NS" value="NS" /></li>
				<li><span></span><@display str=locale.province_NL_N/><input <#attempt>${territory.NL_N}<#recover></#attempt> type="checkbox" name="province" id="NL_N" value="NL_N" /></li>
				<li><span></span><@display str=locale.province_NL_L/><input <#attempt>${territory.NL_L}<#recover></#attempt> type="checkbox" name="province" id="NL_L" value="NL_L" /></li>
				<li><span></span><@display str=locale.province_PM/><input <#attempt>${territory.PM}<#recover></#attempt> type="checkbox" name="province" id="PM" value="PM"/></li>
			</ul>
			<ul class="custom_list round arctic">
				<li><span><input type="checkbox" id="arctic"><@display str=locale.region_arctic/></span><@display str=locale.province_YT/><input <#attempt>${territory.YT}<#recover></#attempt> type="checkbox" name="province" id="YT" value="YT"/></li>
				<li><span></span><@display str=locale.province_NT/><input <#attempt>${territory.NT}<#recover></#attempt> type="checkbox" name="province" id="NT" value="NT"/></li>
				<li><span></span><@display str=locale.province_NU/><input <#attempt>${territory.NU}<#recover></#attempt> type="checkbox" name="province" id="NU" value="NU"/></li>
				<li><span></span><@display str=locale.province_GL/><input <#attempt>${territory.GL}<#recover></#attempt> type="checkbox" name="province" id="GL" value="GL"/></li>
			</ul>
		
			<!-- map -->
			<div class="map">
				  <object id="map" width="410" height="410" data="images/distribution_checklist.svg" type="image/svg+xml"><@display str=locale.checklist_msg7/></object>
			</div>
		</div>
		<p><@display str=locale.checklist_msg8/></p>
		<ul class="distribution_legend custom_list">
			<li class="distribution_native"><@display str=locale.distribution_native/> <input <#attempt>${status.native}<#recover></#attempt> type="checkbox" name="status" id="native" value="native"/></li>
			<li class="distribution_introduced"><@display str=locale.distribution_introduced/> <input <#attempt>${status.introduced}<#recover></#attempt> type="checkbox" name="status" id="introduced" value="introduced"/></li> 
			<li class="distribution_ephemeral"><@display str=locale.distribution_ephemeral/> <input <#attempt>${status.ephemeral}<#recover></#attempt> type="checkbox" name="status" id="ephemeral" value="ephemeral"/></li>
			<li class="distribution_excluded"><@display str=locale.distribution_excluded/> <input <#attempt>${status.excluded}<#recover></#attempt> type="checkbox" name="status" id="excluded" value="excluded"/></li>
			<li class="distribution_extirpated"><@display str=locale.distribution_extirpated/> <input <#attempt>${status.extirpated}<#recover></#attempt> type="checkbox" name="status" id="extirpated" value="extirpated"/></li> 
			<li class="distribution_doubtful"><@display str=locale.distribution_doubtful/> <input <#attempt>${status.doubtful}<#recover></#attempt> type="checkbox" name="status" id="doubtful" value="doubtful"/></li>
		</ul>
	</div>
	
	<div id="display_criteria" class="checklist_content">
		<p><@display str=locale.checklist_msg10/></p>
		<div id="checklist_ranks">
			<ul class="custom_list all">
				<li><input <#attempt>${rank.main_rank}<#recover></#attempt>type="checkbox" id="main_rank"> <@display str=locale.checklist_msg16/></li>
				<li><input <#attempt>${rank.sub_rank}<#recover></#attempt>type="checkbox" id="sub_rank"> <@display str=locale.checklist_msg16/></li>
			</ul>
			<ul class="custom_list">
				<li><input <#attempt>${rank.class}<#recover></#attempt> type="checkbox" class="main_rank" name="rank" id="rank_class" value="class"/> <@display str=locale.rank_class/>
				<li><input <#attempt>${rank.subclass}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_subclass" value="subclass"/> <@display str=locale.rank_subclass/></li>
				<li><input <#attempt>${rank.superorder}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_superorder" value="superorder"/> <@display str=locale.rank_superorder/></li>
			</ul>
			<ul class="custom_list">
				<li><input <#attempt>${rank.order}<#recover></#attempt> type="checkbox" class="main_rank" name="rank" id="rank_order" value="order"/> <@display str=locale.rank_order/></li>
			</ul>
			<ul class="custom_list">
				<li><input <#attempt>${rank.family}<#recover></#attempt> type="checkbox" class="main_rank" name="rank" id="rank_family" value="family"/> <@display str=locale.rank_family/>
				<li><input <#attempt>${rank.subfamily}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_subfamily" value="subfamily"/> <@display str=locale.rank_subfamily/></li>
				<li><input <#attempt>${rank.tribe}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_tribe" value="tribe"/> <@display str=locale.rank_tribe/></li>
				<li><input <#attempt>${rank.subtribe}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_subtribe" value="subtribe"/> <@display str=locale.rank_subtribe/></li>
			</ul>
			<ul class="custom_list">
				<li><input <#attempt>${rank.genus}<#recover></#attempt> type="checkbox" class="main_rank" name="rank" id="rank_genus" value="genus"/> <@display str=locale.rank_genus/>
				<li><input <#attempt>${rank.subgenus}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_subgenus" value="subgenus"/> <@display str=locale.rank_subgenus/></li>
				<li><input <#attempt>${rank.section}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_section" value="section"/> <@display str=locale.rank_section/></li>
				<li><input <#attempt>${rank.subsection}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_subsection" value="subsection"/> <@display str=locale.rank_subsection/></li>
				<li><input <#attempt>${rank.series}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_series" value="series"/> <@display str=locale.rank_series/></li>
			</ul>
			<ul class="custom_list">
				<li><input <#attempt>${rank.species}<#recover></#attempt> type="checkbox" class="main_rank" name="rank" id="rank_species" value="species"/> <@display str=locale.rank_species/>
				<li><input <#attempt>${rank.subspecies}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_subspecies" value="subspecies"/> <@display str=locale.rank_subspecies/></li>
				<li><input <#attempt>${rank.variety}<#recover></#attempt> type="checkbox" class="sub_rank" name="rank" id="rank_variety" value="variety"/> <@display str=locale.rank_variety/></li>
			</ul>
			<div class="clear"></div>
		</div>
		<p><@display str=locale.checklist_msg11/> <input <#attempt>${hybrids.display}<#recover></#attempt> type="checkbox" name="hybrids" id="hybrids" value="true"/>
		<input type="hidden" name="nohybrids" value="false" />
		</p>
		<p><@display str=locale.checklist_msg17/> <input <#attempt>${limitResults.display}<#recover></#attempt> type="checkbox" name="limitResults" id="limitResults" value="true"/>
		<input type="hidden" name="nolimit" value="false" />
		</p>
		<p><@display str=locale.checklist_msg12/>
		<select name="sort" id="sort">
			<option <#attempt>${sort.taxonomically}<#recover></#attempt> name="taxonomically" value="taxonomically"><@display str=locale.checklist_option6/></option>
			<option <#attempt>${sort.alphabetically}<#recover></#attempt> name="alphabetically" value="alphabetically"><@display str=locale.checklist_option7/></option>
		</select>
		</p>
	</div>

	<p id="checklist_footer">
		<input type="submit" value="<@display str=locale.checklist_button1/>"/>
	</p>
</form>	 
<#if isSearch == true>
	<h2>
		  <@display str=locale.checklist_h2_results/>: ${numResults}
		  <span id="results_info" style="float:right;font-size:10px;">
			<#if numResults gt 200 && limitResults.display != "">
				<@display str=locale.checklist_msg18/>
			<#elseif numResults gte 200>
				<@display str=locale.checklist_msg19/>
			</#if>
		  </span>
	</h2>		   
	<#if distributions?has_content == true>					 
	<table class="custom_results_table">
	<thead>
		<tr>
			<th><@display str=locale.rank/></th>
			<th><@display str=locale.scientific_name/></th>
			<th><@display str=locale.habitus/></th>
			<th class="align_center" title="<@display str=locale.province_BC/>"><@display str=locale.province_BC_code/></th>
			<th class="align_center" title="<@display str=locale.province_AB/>"><@display str=locale.province_AB_code/></th>
			<th class="align_center" title="<@display str=locale.province_SK/>"><@display str=locale.province_SK_code/></th>
			<th class="align_center" title="<@display str=locale.province_MB/>"><@display str=locale.province_MB_code/></th>
			<th class="align_center" title="<@display str=locale.province_ON/>"><@display str=locale.province_ON_code/></th>
			<th class="align_center" title="<@display str=locale.province_QC/>"><@display str=locale.province_QC_code/></th>
			<th class="align_center" title="<@display str=locale.province_NB/>"><@display str=locale.province_NB_code/></th>
			<th class="align_center" title="<@display str=locale.province_PE/>"><@display str=locale.province_PE_code/></th>
			<th class="align_center" title="<@display str=locale.province_NS/>"><@display str=locale.province_NS_code/></th>
			<th class="align_center" title="<@display str=locale.province_NL_N/>"><@display str=locale.province_NL_N_code/></th>
			<th class="align_center" title="<@display str=locale.province_NL_L/>"><@display str=locale.province_NL_L_code/></th>
			<th class="align_center" title="<@display str=locale.province_PM/>"><@display str=locale.province_PM_code/></th>
			<th class="align_center" title="<@display str=locale.province_YT/>"><@display str=locale.province_YT_code/></th>
			<th class="align_center" title="<@display str=locale.province_NT/>"><@display str=locale.province_NT_code/></th>
			<th class="align_center" title="<@display str=locale.province_NU/>"><@display str=locale.province_NU_code/></th>
			<th class="align_center" title="<@display str=locale.province_GL/>"><@display str=locale.province_GL_code/></th>
		</tr>
	</thead>
	
	<tbody>
		<#list distributions as distribution>
		<tr class="background_center">
			<td><@display str=("locale.rank_"+distribution.rank?lower_case)?eval /></td>
			<td><a href="taxon/${distribution.taxonId}<@display str=locale.url_language/>">${distribution.fullScientificName}</a></td>
			<td><#list distribution.habit as habitus><#assign str = ("locale.habitus_"+habitus.habit?lower_case)?eval/><#if habitus_has_next><#assign str=str+", "/></#if>${str}</#list></td>
			<td class="distribution_${distribution.BC}"></td>
			<td class="distribution_${distribution.AB}"></td>
			<td class="distribution_${distribution.SK}"></td>
			<td class="distribution_${distribution.MB}"></td>
			<td class="distribution_${distribution.ON}"></td>
			<td class="distribution_${distribution.QC}"></td>
			<td class="distribution_${distribution.NB}"></td>
			<td class="distribution_${distribution.PE}"></td>
			<td class="distribution_${distribution.NS}"></td>
			<td class="distribution_${distribution.NL_N}"></td>
			<td class="distribution_${distribution.NL_L}"></td>
			<td class="distribution_${distribution.PM}"></td>
			<td class="distribution_${distribution.YT}"></td>
			<td class="distribution_${distribution.NT}"></td>
			<td class="distribution_${distribution.NU}"></td>
			<td class="distribution_${distribution.GL}"></td>
		</tr>
		</#list>
	</tbody>
	</table>
	</#if>
<#else>
<h2><@display str=locale.checklist_h2_examples/></h2>
<ul>
	<li><a href="checklist?taxon=0&habit=tree&combination=anyof&province=PM&status=native&status=introduced&status=ephemeral&status=excluded&status=extirpated&status=doubtful"><@display str=locale.checklist_msg13/></a></li>
	<li><a href="checklist?taxon=193&combination=allof&province=YT&province=NT&province=NU&province=GL&status=native"><@display str=locale.checklist_msg14/></a></li>
	<li><a href="checklist?taxon=0&combination=only&province=AB&province=SK&province=MB&status=introduced"><@display str=locale.checklist_msg15/></a></li>
</ul>
</#if>

<#include "_inc/ftl/footer.ftl">